# -*- coding: utf-8 -*-
import scrapy,random,re
from weibo.agent import agent
from weibo import settings

class PhoneSpider(scrapy.Spider):
    name = 'phone'
    allowed_domains = ['weibo.cn']
    base_url='https://weibo.cn/1771861045/info'
    custom_settings = {
        "DEFAULT_REQUEST_HEADERS": {
            'user-Agent': random.choice(agent),
            "Host": "weibo.cn",
        }
    }
    def start_requests(self):
        yield scrapy.Request(self.base_url,callback=self.parse_information,cookies=settings.COOKIE)
    def parse_information(self,response):
        # 提取全文信息
        text1 = response.xpath('//div[@class="c"]//text()').extract()
        # 博主id
        ID=re.findall(r'(\d+)/info',response.url)[0]
        # 博主昵称
        username = re.findall(r'昵称:(.+?)<br/>', response.text)[0]
        # 标签
        tag=re.findall(r'标签:(.+?)工作经历',response.text)[0]
        tag=tag.xpath()
        print(tag)



